Use expect to implement automatic logon script, there are many online, but there is no clear explanation, beginners are generally copied, collection. But why do you want to write this but do not know it. This article uses a shortest example to
Expect everywhere.
The first time I saw expect this command was the first time I was in full volume that's one of the company's cows. A set of automatic deployment, MD5, release of the full online tool written by the shell script, when it's okay,
Recent project requirements, need to write some shell script interaction, the pipeline is not enough time, expect can be very good to implement the interaction between the script, search for information, found that many articles on the Web are
Expect:is based onTcla relatively simple language for a free scripting toolused to implement automated and interactive task programs for communication without manual intervention. For example:ssh ftp , and so on, these programs normally need to
Sometimes we need to send the SSH command to the server in bulk, but it is possible that some of the servers are newly added, and we have not configured SSH encryption, this time will prompt us to enter yes/no or password, etc., expect script
Expect detailed
The expect command is simply to implement tools that automatically interact in interactive software through its built-in commands.
SSH can be used in conjunction with the Spawn command to achieve automatic SSH login. And because it
Expect is a tool for dealing with interactions, usually for scenarios where you need to enter data manually, and you can use expect in your scripts to automate. installation
First check to see if there are any installed expect in the system.
#
1, before using expect, need to install two RPM package,
The code is as follows
Copy Code
# RPM-IHV expect-5.43.0-8.el5.i386.rpm# RPM-IHV expect-devel-5.43.0-8.el5.i386.rpm
2, the batch modifies the password
Use expect to implement automatic login script, there are many online, but there is no clear explanation, beginners are generally copied, collection. But why to write this but do not know it. This article uses a shortest example to illustrate the
SCP is very powerful, but requires manual input of password, of course, you can save the public key in the remote host's ~/.ssh directory, and then do not enter password, but this needs to be configured.Use Sshpass may enter password in command, but
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.